<script type="text/javascript">
$(document).ready(function() {
	$('#weight').priceFormat({  
        prefix: '',  
        centsSeparator: '.',  
        centsLimit: 3,  
        thousandsSeparator: ''  
    });  

	$('#price').priceFormat({  
        prefix: '',  
        centsSeparator: '.',  
        centsLimit: 2,  
        thousandsSeparator: ''  
    });   
});

function readURL(input) {
    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {
        	$("#field").show();
            $('#imageBox')
            	.html("<img id='blah' src='"+e.target.result+"' width='250' height='300'/>");
        };

        reader.readAsDataURL(input.files[0]);
    }
}
</script>

<form enctype="multipart/form-data" id="new-productForm" class="form"
	action="../admin/edit" method="post">
	<input type="hidden" name="id_product"
		value="<?php echo $this->info[0]['id_product']?>">
	<div
		style="width: 1024px; height: 600px; border: 1px solid windowframe; margin: 0 auto;">
		<h2 class="partner-title" style="width: 100%;">
		<?php echo $this->info[0]['name']." - ".utf8_encode($this->info[0]['title'])?>
		</h2>
		<div style="width: 950px; margin: 0 auto;">
			<div class="box">
				<div class="cont">
					<div class="left">
						<label for="category">Categoria*</label>
					</div>
					<select name="id_category" class="required">
						<option value="">Selecione</option>
						<?php $categorias = $this->findAllCategories;
						for ($i = 0; $i < count($categorias); $i++) {

							if($this->info[0]['id_category'] == $categorias[$i]['id_category']){
								echo '<option value='.$categorias[$i]['id_category'].' selected>'.utf8_encode($categorias[$i]['desc'])."</option>";
							}
							else{
								echo "<option value=".$categorias[$i]['id_category'].">".utf8_encode($categorias[$i]['desc'])."</option>";
							}
						}
						?>
					</select>
				</div>

				<div class="cont">
					<div class="left">
						<label for="title">Empresa*</label>
					</div>
					<select name="title" class="required">
						<option value="">Selecione</option>
						<?php $empresas = $this->findAllEnterprises;
						for ($i = 0; $i < count($empresas); $i++) {
							if(utf8_encode($this->info[0]['title']) == utf8_encode($empresas[$i]['enterprise_name'])){
								echo "<option value=".$empresas[$i]['enterprise_id']." selected>".utf8_encode($empresas[$i]['enterprise_name'])."</option>";
							}else{
								echo "<option value=".$empresas[$i]['enterprise_id'].">".utf8_encode($empresas[$i]['enterprise_name'])."</option>";
							}
						}
						?>
					</select>
				</div>

				<div class="cont">
					<div class="left">
						<label for="name">Nome*</label>
					</div>
					<input type="text" name="name" size="25" class="required"
						value="<?php echo $this->info[0]['name']?>" />
				</div>

				<div class="cont">
					<div class="left">
						<label for="nat">Nacionalidade</label>
					</div>
					<input type="text" name="nationality"
						value="<?php echo $this->info[0]['nationality']?>">
				</div>

				<div class="cont">
					<div class="left">
						<label for="year">Ano de Lançamento</label>
					</div>
					<input id="year" type="text" name="year"
						value="<?php echo $this->info[0]['year']?>">
				</div>

				<div class="cont">
					<div class="left">
						<label for="price">Preço*</label>
					</div>
					<input id="price" type="text" name="price" class="required"
						value="<?php echo $this->info[0]['price']?>">
				</div>

				<div class="cont">
					<div class="left">
						<label for="quantity">Quantidade</label>
					</div>
					<input class=".mask-preco" type="text" name="quantity"
						value="<?php echo $this->info[0]['quantity']?>">
				</div>

				<div class="cont">
					<div class="left">
						<label for="weight">Peso</label>
					</div>
					<input type="text" id="weight" name="weight"
						value="<?php echo $this->info[0]['weight']?>"> gramas
				</div>

				<div class="cont">
					<div class="left">
						<label for="desc">Descrição*</label>
					</div>
					<textarea id="desc" name="desc" rows="7" cols="50">
					<?php echo $this->info[0]['description']?>
					</textarea>
				</div>

				<div class="cont">
					<div class="left">
						<label>Imagem</label>
					</div>
					<input name="image" type="file" size="30" id="image"
						onchange="readURL(this);" />
				</div>
				<div>
					<input type="submit" name="send" value="Editar"> <input
						type="reset" name="reset" value="Limpar Formulário">
				</div>
			</div>
			<div class="box" style="margin: 20px 0 0 60px; width: 35%">
				<fieldset id="field">
					<legend>Imagem</legend>
					<div id="imageBox" style="margin: 10px 10px 10px 10px; text-align: center; ">
						<img width="250" height="300" alt=""
							src="<?php echo $this->info[0]['image']?>">
					</div>
				</fieldset>
			</div>
		</div>
	</div>
</form>
